let mongoose = require('mongoose'),
    memberUsers = mongoose.model('member_users');

module.exports = (req, res) => {
    let params = req.query;

    if(!params.userName){
        res.json(resFail('帐号不能为空！'));
        return false;
    }
    if(!params.passWord){
        res.json(resFail('密码不能为空！'));
        return false;
    }

    memberUsers.findOne({
        $or: [
            { userName: params.userName },
            { mobile: params.userName }
        ],
        passWord: params.passWord
    }, (err, doc) => {
        if(err){
            res.json(resFail('登陆失败'));
        }else{
            if(doc){
                res.json({
                    result: 1,
                    data: {
                        birthday: doc.birthday,
                        autograph: doc.autograph,
                        userGroup: doc.userGroup,
                        avater: doc.avater,
                        sex: doc.sex,
                        address: doc.address,
                        integral: doc.integral,
                        mobile: doc.mobile,
                        email: doc.email,
                        userName: doc.userName
                    }
                })
            }else{
                res.json(resFail('查无此人'));
            }
        }
    })
}